﻿#ifndef LOGHANDLER_H
#define LOGHANDLER_H

#include <QObject>
#include <QFile>
#include <QTextStream>
#include <QMutex>

class LogHandler : public QObject
{
    Q_OBJECT
public:
    static LogHandler *instance();

    static void install();

private:
    LogHandler(QObject *parent = nullptr);
    ~LogHandler();

    static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg);

    static QFile *m_logFile;
    static QTextStream *m_logStream;
    static QTextStream *m_consoleStream;

    static QMutex m_mutex;
    static LogHandler *m_instance;
};

#endif // LOGHANDLER_H
